/* Janus Chat - Version 1.0
 * Authors: Matthew Perry
 *          Michael Freid
 *          Marc Latou
 *          Richard Lee
 *
 * The Janus Chat Client is a highly secured
 * peer-to-peer chat client designed to facilitate
 * the transfer of sensitive data or as a communication
 * medium for the extra paranoid
 *
 * This file contains the implementation for the some
 * Unix specific exceptions for the unix specific
 * library classes (Socket, ServerSocket). It's
 * important to seperate these for cross-compatability */

#ifndef UNIX_EXCEPTIONS_H
#define UNIX_EXCEPTIONS_H

#include <string.h>
#include <netdb.h>
#include "exceptions.h"

/* These two exceptions only work on unix because
 * they use the errno and h_errno variables and the
 * strerror() and hstrerror() functions to get
 * human readable error strings. Windows has
 * problems with these functions. These exceptions
 * have been seperated out for cross compatability.
 * They will now only be used with the Server because
 * the server requires a Unix system */

class SocketException : public BaseException
{
    protected:
        //Override the errorString function to get
        //a readable string from the errno
        string errorString() const
        {
            string retval( strerror( errno ) );
            return retval;
        }

    public:
        SocketException( const string& str )
            : BaseException( str ) {}
        ~SocketException() throw() {}
};

class LookupException : public BaseException
{
    protected:
        //Override the errorString function to get
        //a readable string from the h_errno
        string errorString() const
        {
            string retval( hstrerror( h_errno ) );
            return retval;
        }

    public:
        LookupException( const string& str )
            : BaseException( str ) {}
        ~LookupException() throw() {}
};

#endif // UNIX_EXCEPTIONS_H
